
const fs = require('fs')
const express = require('express');
const app = express();
const port = '3300'

// 指定html
app.get('/index.html', function(req, res) {
  res.sendFile(__dirname + req.path);
});

// 配置Mock数据
app.get('/home', function(req, res) {
  res.setHeader('Content-Type', 'application/json; charset=utf-8');
  fs.readFile('./mock/data/area.min.json', function(err, data) {
    if (err) throw err;

    res.json(JSON.parse(data));
  });
});

// 监听端口
app.listen(port, function () {
  console.log(`mock app listening at http://localhost:${port}`);
});